package com.example.teesystem.entityDto;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.teesystem.common.cache.UserCache;
import com.example.teesystem.common.utils.TimeUtil;
import com.example.teesystem.entity.User;
import com.example.teesystem.entity.Violation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author pxr
 * @data 2022/4/12 15:38
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ViolationDto {
    private Integer id;
    private Integer studentId;
    private Integer paperId;
    private Integer num;
    private String uploadTime;
    private String studentName;
    private String paperName;

    public ViolationDto(Violation violation){
        BeanUtils.copyProperties(violation,this);
        this.uploadTime = TimeUtil.dateToString(violation.getUploadTime());
        User user = new User();
        user.setMyName("用户未找到");
        this.studentName = UserCache.userMap.getOrDefault(violation.getStudentId(),user).getMyName();
    }
}
